/**
 * Created by KyLin on 2016/12/6.
 */
import React, {Component, PropTypes} from 'react';

export default class AddTodo extends Component {
    handlerClick() {
        let node = this.refs.input,
            text = node.value.trim();
        this.props.onAddClick(text);
        node.value = '';
    }

    render() {
        const aa = () => {
            return (
                <div>
                    <input type="text" ref='input'/>
                    <button type="button" onClick={() => this.handlerClick()}>Add</button>
                </div>
            )
        };
        return (
            <div>
                {
                    this.props.show ? aa() : ''
                }
            </div>
        )
    }
}

AddTodo.propTypes = {
    onAddClick: PropTypes.func.isRequired
};